%{
    This file is part of StemCellQC, a video bioinformatics software
    toolkit for analysis of phase contrast microscopy videos.
    Copyright 2013-2015 Vincent On. [vincenton001-at-gmail.com]

    StemCellQC is free software: you can redistribute it and/or 
    modify it under the terms of the GNU General Public License as 
    published by the Free Software Foundation, either version 3 of the 
    License, or (at your option) any later version.

    StemCellQC is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with StemCellQC.  If not, see <http://www.gnu.org/licenses/>.
%}

function skip_frame = fun_automate_multi( index , track_seg ,skip_frame )
global mov

try

    temp = track_seg;


    %====
    %Part 2: gettting region statistics
    
    stats = regionprops( temp, ....
        'Area', ...
        'Perimeter', ...
        'Centroid', ...
        'Extent', ...
        'Solidity', ...
        'Orientation', ...
        'MajorAxisLength', ...
        'MinorAxisLength', ...
        'Eccentricity', ...
        'Extrema' );
    
    % compute statistics perimeter pixels with respect to the centroid
    D = cen2peri_dist( temp );
    Min_rad = min(D);
    Max_rad = max(D);
    Avg_rad = mean(D);
    
    % compute difference of average intensities of background and silhouette
    % regions
    [avg_intensity, max_intensity, min_intensity, bright_area] = intensity_extract(index,temp, 75);
    
    bright_ratio = bright_area/stats.Area;
    
    % compute number of protrusions and area of protrusions
    
    [N_protrusions, Prot_area] = protrusions(index,temp, 25);
    Prot_ratio = Prot_area/stats.Area;
    
    mov(index).features( 1 ) = { stats.Area };
    mov(index).features( 2 ) = { stats.Perimeter };
    mov(index).features( 3 ) = { stats.Centroid(1) };
    mov(index).features( 4 ) = { stats.Centroid(2) };
    mov(index).features( 5 ) = { stats.Extent };
    mov(index).features( 6 ) = { stats.Solidity };
    mov(index).features( 7 ) = { stats.Orientation };
    mov(index).features( 8 ) = { stats.MajorAxisLength };
    mov(index).features( 9 ) = { stats.MinorAxisLength };
    mov(index).features( 10 ) = { stats.Eccentricity };
    mov(index).features( 11 ) = { stats.Extrema };
    mov(index).features( 12 ) = { Min_rad };
    mov(index).features( 13 ) = { Max_rad };
    mov(index).features( 14 ) = { Avg_rad };
    mov(index).features( 15 ) = { avg_intensity };
    mov(index).features( 16 ) = { max_intensity };
    mov(index).features( 17 ) = { min_intensity };
    mov(index).features( 18 ) = { bright_ratio };
    mov(index).features( 19 ) = { N_protrusions };
    mov(index).features( 20 ) = { Prot_ratio };
    
    skip_frame = 0;
catch exception
    skip_frame = skip_frame + 1;
    disp( ['Skiping frame ' num2str( index )]);
end